cmake_minimum_required(VERSION 3.16)
project(cwtrainerX VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找GTK4库
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK4 REQUIRED gtk4)

# 查找PortAudio库用于音频处理
pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)

# 包含头文件目录
include_directories(${GTK4_INCLUDE_DIRS} ${PORTAUDIO_INCLUDE_DIRS})

# 添加源文件
set(SOURCES
    main.cpp
    cwtrainer.cpp
    config.cpp
    morse.cpp
    audio.cpp
)

# 添加头文件
set(HEADERS
    cwtrainer.h
    config.h
    morse.h
    audio.h
)

# 创建可执行文件
add_executable(cwtrainerX ${SOURCES} ${HEADERS})

# 链接库
target_link_libraries(cwtrainerX ${GTK4_LIBRARIES} ${PORTAUDIO_LIBRARIES})

# 安装配置
install(TARGETS cwtrainerX DESTINATION bin)

# 设置编译选项
target_compile_options(cwtrainerX PRIVATE -Wall -Wextra -pedantic -g)